<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>任务统计</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui/css/layui.css">
    <link rel="stylesheet" href="../css/scroll-bar.css">
    <link rel="stylesheet" href="../css/sub-page.css">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../lib/nprogress/nprogress.css">
</head>

<body>
    <div class="ok-body">
        <!--面包屑导航区域-->
        <div class="ok-body-breadcrumb">
            <span class="layui-breadcrumb">
                <a><cite>首页</cite></a>
                <a><cite>任务管理</cite></a>
                <a><cite>任务统计</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);" title="刷新">
                <i class="layui-icon layui-icon-refresh"></i>
            </a>
        </div>
        <!--模糊搜索区域-->
        <div class="layui-row ok-search">
            <input class="layui-input" placeholder="开始日期" autocomplete="off" id="startTime">
            <input class="layui-input" placeholder="截止日期" autocomplete="off" id="endTime">
            <% if(isadmin) { %> 
                <div class="layui-inline">
                    <input class="layui-input" name="id" id="username" autocomplete="off" placeholder="请输入用户名">
                </div>
            <% } %>
           
            <button class="layui-btn" data-type="reload" id="search">搜索</button>
        </div>
        <!--工具栏-->
        <!-- <okToolbar>
            <button class="layui-btn" id="add">
                <i class="layui-icon">&#xe61f;</i>新建任务
            </button>
            <span>共有数据：<i id="countNum">0</i> 条</span>
        </okToolbar> -->
        <!--数据表格-->
        <table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
        <input class="layui-hide" id='id' value="">
        <input class="layui-hide" id='isadmin' value="">
        <!--  <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
              <button class="layui-btn layui-btn-sm" lay-event="add">新建任务</button>
            </div>
          </script> -->
    </div>
    <!--js逻辑-->
    <script src="../lib/layui/layui.js"></script>
    <script src="../lib/nprogress/nprogress.js"></script>
    <script>
        NProgress.start();
    window.onload = function () {
        NProgress.done();
    }
    layui.use(['element', 'table', 'form', 'jquery','laydate'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#startTime',
            type: "datetime"
        });

        laydate.render({
            elem: '#endTime',
            type: "datetime"
        });
        table.render({
            elem: '#tableId',
            url: '/statistics/task_statistics?taskid='+$('#id').val(),
            cellMinWidth: 80,
            page: false,
            id:'folderlist',
            toolbar: '#toolbarDemo',
            totalRow: true,
            where:{
                isadmin:$('#isadmin').val()
            },
            cols: [[
                {field: 'username', title: '用户名',align:'center'},
                {field: 'truename', title: '真实名称',align:'center'},
                {field: 'actions', title: '执行类别', templet: '#actionTpl',width:95,align:'center',totalRowText: '合计'},
                {field: 'submitcount', title: '处理量',align:'center', totalRow: true},
                {field: 'rejectcount', title: '驳回量',align:'center',style:'color: red;', totalRow: true},    
                {field: 'works',title: '有效工作量', /* templet: '#workTpl',  */align: 'center', totalRow: true},        
                {templet: '#timeTpl', title: '累计时长(分)',align:'center', totalRow: true}
            ]],
            done: function (res, curr, count) {
                //$("#countNum").text(count);
            }
        });

        var active = {
            reload: function(){
                var username = $('#username').val();
                var start=$('#startTime').val();
                var end=$('#endTime').val();
                
                //执行重载
                table.reload('folderlist', {
                    page: false
                    ,where: {
                        key:{
                            username: username||'',
                            start:start,
                            end:end                       
                        },
                        isadmin:$('#isadmin').val()
                    }
                });
            }
        };

        $('#search').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        $('#username').on('keydown',function(e){
            if(e.keyCode=='13'){
                $('#search').click();
            }
        }); 
    })
</script>
    <script type="text/html" id="timeTpl">
        <label href="javascript:;" title="累计时长" >
            {{ Math.ceil(d.spent/60,2)}}
        </label>
    </script>
    <script type="text/html" id="actionTpl">
        <a href="javascript:;" title="执行类别"  class="layui-btn layui-btn-xs">
            {{#  if(d.actions === 1){ }}
            标注
            {{#  } }}     
            {{#  if(d.actions === 2){ }}
            检查
            {{#  } }}
            {{#  if(d.actions === 3){ }}
            抽查
            {{#  } }}     
        </a>
    </script>
</body>

</html>